/*
 * @Author: your name
 * @Date: 2020-11-24 20:31:11
 * @LastEditTime: 2020-11-24 21:11:01
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \generator-joey-vue\generators\app\index.js
 */
const Generator = require('yeoman-generator')

module.exports = class extends Generator {
  prompting () {
    return this.prompt([
      {
        type: 'input',
        name: 'name',
        message: 'Your Project name?',
        default: this.name
      }
    ])
    .then(answers => {
      this.answers = answers
    })
  }
  writing () {
    // 把每一个文件都通过模板转换到目标路径
    const templates=[
      'public/favicon.ico',
      'public/index.html',
      'src/views/hello.vue',
      'src/App.vue'
    ]
    templates.forEach(item => {
      // item => 每个文件路径
      this.fs.copyTpl(
        this.templatePath(item),
        this.destinationPath(item),
        this.answers
      )
    })
  }
}